def sortColumns(matrix): # DO NOT modify this line 
    # TODO: add your code here
    # 转置矩阵
    transposed = list(zip(*matrix))
    # 对每一列进行排序
    sorted_columns = [sorted(col) for col in transposed]
    # 再次转置以恢复行结构
    sorted_matrix = list(zip(*sorted_columns))
    # 将元组转换为列表
    return [list(row) for row in sorted_matrix]

# === DO NOT modify the code below === 
def main():
    mx1 = []
    n = int(input())
    for i in range(n):
        numbers = [eval(x) for x in input().split()]
        mx1.append(numbers)
    mx2 = sortColumns(mx1)
    for row in mx2:
        print(" ".join(map(str,row)))
    
if __name__ == "__main__":
    main()
# === DO NOT modify the code above ===
